{{include './index_header.html' '收藏'}}
<style>
    h3{
        text-align: center;
    }
</style>
<div class="mui-content">
    {{if data}}
    <ul class="mui-table-view"> 
        {{each data song}}
        <li class="mui-table-view-cell mui-collapse">
            <a class="mui-navigate-right" href="#">
                {{song.song}}
            </a>
            <div class="mui-collapse-content">
                <a class="mui-btn mui-btn-danger cancel" data-id="{{song.sid}}">
                    取消收藏
                </a>
                <p>
                    
                    <audio controls src="https://music.163.com/song/media/outer/url?id={{song.sid}}"></audio>
                </p>
            </div>
        </li>
        {{/each}}
    </ul>
    {{else}}
    <h3></h3>

    {{/if}}
</div>

<script>
var name = $.cookie('name')
console.log(name);
if(!name || name == 'undefined'){
    $('h3').html('未登录，请先登录')
}
if($('.mui-table-view').children().length == 0){
    $('.mui-table-view').html('收藏列表为空，快去收藏吧')
}
$('.cancel').click(function(e){
    e.preventDefault()
    
    mui.confirm('确定取消收藏','系统提示',['确定','取消'],function(e){
        if(e.index == 0){
            $.get('/user/cancel?id='+$('.cancel').data().id,(data)=>{
                mui.alert(data.msg,'系统提示','确定',function(){
                    location.reload()

                })
            })
        }
    
    })
})

</script>
</body>
</html>